***************************************
**** 	Table A17:	Sleep 		****
***************************************

use "$dir/Data/analysis_main.dta", clear


recode sleep_scale (1=3) (3=1), gen(sleep_scale2)	// reverse scale

// with baseline controls

eststo clear
eststo: reghdfe sleep_hours cash loan_moneylender numloans_worry bs_labor_30_nm bs_labor_30_miss i.future_fin_worry_nm if pid1==1 , vce(robust) a(roundgroup)
	qui summarize sleep_hours if e(sample)==1 & cash==0
	qui estadd scalar cont = r(mean)
eststo: reghdfe sleep_scale2 cash loan_moneylender numloans_worry bs_labor_30_nm bs_labor_30_miss i.future_fin_worry_nm if pid1==1 , vce(robust) a(roundgroup)
	qui summarize sleep_scale2 if e(sample)==1 & cash==0
	qui estadd scalar cont = r(mean)
eststo: reghdfe sleep_well cash loan_moneylender numloans_worry bs_labor_30_nm bs_labor_30_miss i.future_fin_worry_nm if pid1==1 , vce(robust) a(roundgroup)
	qui summarize sleep_well if e(sample)==1 & cash==0
	qui estadd scalar cont = r(mean)

#delimit ;
local tablerow cash;

esttab using "$oa/$t/Table_A17.tex", 
    b(3) se booktabs star(* .1 ** .05 *** .01) nonotes nomtitles 
    replace label style(tex) gaps keep(`tablerow') order(`tablerow') 
    stats(cont N, labels("Control group mean" "N: workers") fmt(%9.2fc %9.0fc))    
	prehead("{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} 
	\begin{tabular}     
	{@{\extracolsep{4pt}}l*{10}{>{\centering\arraybackslash}m{3.5cm}}@{}}      \toprule  
	&\multicolumn{1}{c}{Hours of sleep}  &\multicolumn{1}{c}{Sleep quality scale}  &\multicolumn{1}{c}{Had a good sleep}  \\
	") ;
		
#delimit cr	

	

